/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ui.user.other;

import hibernate.dao.CenterDAO;
import hibernate.dao.CourseDAO;
import hibernate.entity.Centers;
import hibernate.entity.Courses;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import ui.common.AbstractUIBean;
import util.Converter;

/**
 *
 * @author Neo
 */
@ManagedBean
@RequestScoped
public class IndexBean extends AbstractUIBean {

    /**
     * Creates a new instance of IndexBean
     */
    int centerID, courseID;
    CenterDAO cenDao = new CenterDAO();
    CourseDAO courseDao = new CourseDAO();
    List<Centers> allCenter;
    List<Courses> allCourse;

    public int getCenterID() {
        return centerID;
    }

    public void setCenterID(int centerID) {
        this.centerID = centerID;
    }

    public int getCourseID() {
        return courseID;
    }

    public void setCourseID(int courseID) {
        this.courseID = courseID;
    }

    public List<Centers> getAllCenter() {
        return allCenter;
    }

    public List<Courses> getAllCourse() {
        return allCourse;
    }

    public IndexBean() {
        allCourse = new ArrayList<Courses>();
        allCenter = cenDao.readAll();
        centerID = allCenter.get(0).getCenterId();
        courseID = allCourse.get(0).getCourseId();
        for (Centers centers : allCenter) {
            allCourse.addAll(centers.getCourseses());
        }
    }

    public void pickCenter(Centers c) {
        allCourse = Converter.iteratorToList(c.getCourseses().iterator());
    }

    public String getAdmissionLink() {
        return APP_DOMAIN + "/resources/fileupload/admisstion/admission.jpg";
    }
}
